<template>
  <div v-if="data.length>0">
    <h1>{{index|fmtOrder2CN}}、{{title}} 共{{data.length}}题</h1>
    <ul>
      <li class="item" v-for="(item, index) in data" :key="index">
        <button @click="remove(item)" class="btn-add">移出试题车</button>
        <h4>{{index+1}}.[{{item.type|fmtSubjectType}}]{{item.name}}</h4>
        <div style="color:#888;font-size:14px;padding:10px 5px;">{{item.author}}-{{item.createTime}}</div>
        <fieldset style="padding:10px;" v-if="checkIsXZT(item.type)">
          <legend>选项</legend>
          <div
            style="padding:10px;"
            v-for="(option, i) in item.options"
            :key="i"
          >{{i|fmtOrder2ABC}}.{{option.val}}</div>
        </fieldset>
      </li>
    </ul>
  </div>
</template>

<script>
import { createNamespacedHelpers } from "vuex";
let { mapMutations } = createNamespacedHelpers("subject");
export default {
  props: ["title", "data", "index"],
  methods: {
    ...mapMutations(["removeFromCart"]),
    remove(item) {
      this.removeFromCart(item.id);
    }
  }
};
</script>
